package com.upf1sh.controller;

import com.upf1sh.bean.IniectionRobot;
import com.upf1sh.service.IniectionRobotService;
import com.upf1sh.utils.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description:
 * @Title: IniectionRobotController
 * @Package com.upf1sh.controller
 * @Author:
 * @CreateTime: 2024/9/19 22:08
 */
@CrossOrigin
@RestController
@RequestMapping("/iniectionRobot")
public class IniectionRobotController {

    @Resource
    private IniectionRobotService  iniectionRobotService;


    @GetMapping("/list")
    public Result getList(IniectionRobot entity) {
        List<IniectionRobot> list = iniectionRobotService.getList(entity);
        return Result.ok().data("list",list);
    }

    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Integer id) {
        IniectionRobot entity = iniectionRobotService.getById(id);
        return Result.ok().data("entity",entity);
    }

    @PostMapping("add")
    public Result add(@RequestBody IniectionRobot entity) {
        iniectionRobotService.add(entity);
        return Result.ok();
    }

    @PostMapping("delete")
    public Result delete(@RequestBody IniectionRobot entity) {
        iniectionRobotService.delete(entity);
        return Result.ok();
    }

    @PostMapping("update")
    public Result update(@RequestBody IniectionRobot entity) {
        iniectionRobotService.update(entity);
        return Result.ok();
    }

    @GetMapping("/query-device-property/{pig_fiel}/{injection_type}")
    public Result queryDeviceProperty(@RequestParam("pigFiel") String pigFiel, @RequestParam("injectionType") String injectionType) {
        IniectionRobot entity = new IniectionRobot();
        entity.setPigFiel(pigFiel);
        entity.setInjectionType(injectionType);
        IniectionRobot info = iniectionRobotService.getInfo(entity);
        return Result.ok().data("entity",entity);
    }
}
